
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<script>
			window.onload  = function(){
				//1.抓元素
				var btn = document.getElementById("btn");
				var pic = document.getElementById("pic");
				//3.声明一个变量 让图片名称改变
				var c = 1;
				//2.加点击事件
				btn.onclick = function(){
					//4.加定时器
					setInterval(function(){
						c++;
						document.title = c;
						c = (c==20) ? 1 : c;
						pic.setAttribute('src','images/'+c+'.png');
					},150)
				}
			}
		</script>
	</head>
	<body>
		<input type="button" value="点我呀" id="btn" />
		<br /><br />
		<img src="images/1.png" id='pic'/>
	</body>
</html>
